package com.mikao.controller.manager;

import com.mikao.dto.bo.ManagerForm;
import com.mikao.dto.bo.ReqDataTableDto;
import com.mikao.dto.vo.RspDataTableDto;
import com.mikao.dto.vo.SysManagerDto;
import com.mikao.service.SysUserService;
import org.springframework.context.annotation.Scope;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;


/**
 * @author KennyDavid
 */
@RestController
@RequestMapping(value = "/management", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Scope("prototype")
public class SysUserController {


    private SysUserService sysUserService;

    public SysUserController(SysUserService sysUserService) {
        this.sysUserService = sysUserService;
    }

    @GetMapping("/managerList")
    public RspDataTableDto<SysManagerDto> findManagerList(@ModelAttribute ReqDataTableDto reqDataTableDto) {
        return sysUserService.findManagerList(reqDataTableDto);
    }

    @PostMapping("/saveManager")
    public void saveManager(@ModelAttribute ManagerForm managerForm) {
        sysUserService.saveManager(managerForm);
    }

    @GetMapping("/removeManager/{id}")
    public void removeManager(@PathVariable Long id) {
        sysUserService.removeManager(id);
    }

    @GetMapping("/isManagerExist")
    public Boolean checkManagerExists(String account) {
        return sysUserService.checkSysUserExists(account);
    }

    @GetMapping("/resetPassword/{id}")
    public void resetPassword(@PathVariable Long id) {
        sysUserService.resetPassword(id);
    }

}
